package com.yiren.dbaa.net.rtk.impl;

import android.app.Activity;
import android.content.Context;

import com.yiren.backstage.communication.thread.RTKConnection;
import com.yiren.dbaa.net.rtk.IRtkConnect;
import com.yiren.dbaa.view.toast.MessageBox;

/**
 * Created by WANGRONGXIANG
 * on 2022/6/7
 * Describe
 */
public class RtkConnectApiImpl implements IRtkConnect {

    private Context context;

    public RtkConnectApiImpl(Context context) {
        this.context = context;
    }

    @Override
    public void connect(String deviceRover) {
        RTKConnection rtkConnection = RTKConnection.getInstance(context);
        rtkConnection.setOnConnectionListener((state, message) -> ((Activity) context).runOnUiThread(() -> MessageBox.show(context, message)));
        rtkConnection.setDiffId(deviceRover);
        rtkConnection.start();
    }
}
